<template>
  <div class="pd-20">
    <el-input v-model="memberName"
              @keyup.enter.native="handleTableMethod"
              placeholder="请输入患者名称"
              clearable
              @clear="handleQuery"
              class="w-200" />
    <el-button type="primary"
               @click="handleQuery">查 询</el-button>
    <el-table :data="tableData"
              style="width: 100%"
              border
              class="mt-20">
      <el-table-column align="center"
                       type="index"
                       label="序号">
      </el-table-column>
      <el-table-column align="center"
                       prop="memberName"
                       label="患者名称"
                       width="100">
      </el-table-column>
      <el-table-column label="解读项">
        <template slot-scope="scope">
          <el-tag v-for="tag in scope.row.tags"
                  :key="tag"
                  effect="dark"
                  style="margin-bottom:5px;">
            {{tag}}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       label="旧医生"
                       width="150">
        <template slot-scope="scope">
          <span>{{scope.row.fromDoctorDto.nickName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       width="150"
                       label="新医生">
        <template slot-scope="scope">
          <span>{{scope.row.toDoctorDto.nickName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       width="180"
                       label="日期"
                       :formatter="formatterDate">
      </el-table-column>
    </el-table>
    <p align="right"
       class="mt-20">
      <el-pagination background
                     @current-change="handleCurrentChange"
                     :current-page.sync="pageIndex"
                     :page-size="pageSize"
                     layout="total, prev, pager, next"
                     :total="totalNum">
      </el-pagination>
    </p>

  </div>
</template>

<script>
  export default {
    name: "doctorCheckChangeList",
    data () {
      return {
        loading: false,
        tableData: [],
        pageIndex: 1,
        pageSize: 20,
        memberName: '',
        totalNum: 0
      }
    },
    methods: {
      handleQuery() {
        this.pageIndex = 1
        this.handleTableMethod()
      },
      handleTableMethod () {
        let param = {
          memberName: this.memberName,
          pageSize: this.pageSize,
          pageIndex: this.pageIndex - 1
        };
        this.post(this.api.getDoctorCheckChangeList.url, param).then((res) => {
          if (res.data.code === '200') {
            let resData = res.data.object;
            this.tableData = resData;
            this.totalNum = 200;
          }
        });
      },
      formatterDate (row) {
        return this.commonFunction.timestampFormat(new Date(row.createTime), 'yyyy-MM-dd hh:mm')
      },
      handleCurrentChange (val) {
        this.pageIndex = val;
        this.handleTableMethod();
      },
    },
    created () {
      this.handleTableMethod();
    }
  }
</script>

<style scoped>
  .el-tag + .el-tag {
    margin-left: 10px;
  }
</style>
